package org.umlviewer.paint;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Polygon;

/** Draws a triangular arrow head at the end of a FigEdge */

public class ArrowHeadHalfTriangle extends ArrowHead {

    static final long serialVersionUID = -7257932581787201038L;  

    //metodo tomado de la clase CurvedArrow de JFlap
    public void paint(
            final Graphics g,
            final Point start,
            final Point end,
            final Color lineColor,
            final Color fillColor)
    {
        int endX, endY;
        double angle = Math.atan2((double) (start.x - end.x),
                        (double) (start.y - end.y));
        angle += ARROW_ANGLE;
        endX = ((int) (Math.sin(angle) * ARROW_LENGTH)) + end.x;
        endY = ((int) (Math.cos(angle) * ARROW_LENGTH)) + end.y;
        g.drawLine(end.x, end.y, endX, endY);
        angle -= 2 * ARROW_ANGLE;
        endX = ((int) (Math.sin(angle) * ARROW_LENGTH)) + end.x;
        endY = ((int) (Math.cos(angle) * ARROW_LENGTH)) + end.y;
        g.drawLine(end.x, end.y, endX, endY);
    }
    
    /** The angle for the arrow heads. */
    private static double ARROW_ANGLE = Math.PI / 10;

	/** The length of the arrow head edges. */
    private static double ARROW_LENGTH = 15;
    
} /* end class ArrowHeadHalfTriangle */
